<!--
 * @description 小组管理--管理员信息
 * @author dumeng
 * @date 2021/9/18
 -->
<template>
  <div class="xqxz-group-manager-page">
    <el-collapse-transition>
      <div class="common-search merge">
        <span class="svg-container">
          <svg-icon icon-class="search" />
        </span>
        <el-input
          v-model.trim="listQuery.userRealName"
          placeholder="请输入姓名搜索"
          class="search-input"
          @keyup.enter.native="handleFilter"
        />
        <div class="common-search-btn">
          <el-button class="filter-item" type="primary" @click="handleFilter">搜索</el-button>
          <el-button class="filter-item" type="primary" @click="resettingBtn">重置</el-button>
        </div>
      </div>
    </el-collapse-transition>
    <section class="main-table">
      <v-table
        :list="list"
        tag="xqxzgroupManager"
        :list-loading="listLoading"
        :selection="false"
        :filter-column="filterColumn"
      />
      <pagination
        v-show="total>0"
        :total="total"
        :page.sync="listQuery.page"
        :limit.sync="listQuery.limit"
        @pagination="getList"
      />
    </section>
  </div>
</template>

<script>
import Pagination from '@/components/Pagination'
import VTable from '@/components/Table'
import { queryManage } from '../api/groupManage'
import CryptoJS from '@/utils/aesJiaJM'
export default {
  name: 'XqxzGroupManager',
  components: { Pagination, VTable },
  props: {
    groupId: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      list: [],
      total: 0,
      listLoading: false,
      listQuery: {
        page: 1,
        limit: 10,
        userRealName: ''
      }
    }
  },
  created() {
    this.getList()
  },
  methods: {
    filterColumn(scope, item) {
      if (item === 'userIdnumber' || item === 'userPhone') {
        return this.handleDecrypt(scope.row[item])
      } else {
        return scope.row[item]
      }
    },
    handleDecrypt(str) {
      return CryptoJS.$aesJieM(str)
    },
    handleFilter() {
      this.listQuery.page = 1
      this.getList()
    },
    resettingBtn() {
      this.listQuery.userRealName = ''
      this.listQuery.page = 1
      this.getList()
    },
    /**
     * 选项卡切换
     */
    handleTabClick() {
      this.listQuery.page = 1
      this.getList()
    },
    getList(obj) {
      this.listLoading = true
      const query = {
        groupId: this.groupId,
        page: obj ? obj.page : this.listQuery.page,
        pageSize: obj ? obj.limit : this.listQuery.limit,
        userRealName: this.listQuery.userRealName
      }
      return new Promise((resolve, reject) => {
        queryManage(query).then(response => {
          this.list = response.data.data.rows
          this.total = response.data.data.total
          this.listLoading = false
        }).catch(error => {
          reject(error)
          this.listLoading = false
        })
      })
    }
  }
}
</script>

<style lang="scss">
  .xqxz-group-manager-page {
    padding: 0 10px;
    .common-search {
      background-color: #fff;
      padding: 0 10px;

      .svg-container {
        padding: 0 5px 0 10px;
        color: #bfced6;
        vertical-align: middle;
        display: inline-block;

        &_login {
          font-size: 10px;
        }
      }

      .search-input {
        width: 40%;
        position: relative;
        //
        //&:after {
        //  content: '';
        //  position: absolute;
        //  left: -25px;
        //  right: 0;
        //  bottom: 8px;
        //  height: 1px;
        //  background: rgba(226, 227, 232, 1);
        //}

        input {
          outline: none;
          background: transparent;
          border: none;
          outline: medium;
          padding: 0;

          &:focus {
            outline: none;
            background-color: transparent;
          }
        }
      }

      .common-search-btn {
        display: inline-block;
        float: right;

        .el-button.is-round {
          padding: 10px 30px;
          margin-right: 34px;
        }

        .common-search-more {
          font-size: 14px;
          font-weight: 500;
          @include font-color($mainColor);
          cursor: pointer;
          margin-left: 10px;
        }
      }

      &.merge {
        height: 50px;
        line-height: 50px;
      }

      &.separate {
        .common-search-inner {
          padding-top: 10px;

          .search-inner-item {
            .item-label {
              height: 30px;
              line-height: 30px;
              font-size: 14px;
              color: #a6a6a6;
              font-weight: 400;
            }

            .el-checkbox__label {
              font-weight: 400;
            }

            .el-input {
              position: relative;

              .el-input__inner {
                border: none;
                padding: 0;
              }

              &:after {
                content: '';
                height: 1px;
                background-color: #e2e3e8;
                position: absolute;
                left: 0;
                right: 0;
                bottom: 0;
              }
            }
          }
        }

        .common-search-btn {
          text-align: center;
          display: block;
          float: none;
          height: 56px;
          line-height: 56px;
        }
      }
    }
    .classify-tab {
      width: 100%;
      margin-bottom: 10px;
      padding: 0 10px;
      background-color: #fff;
      border-radius: 4px;

      .el-tabs__nav-wrap::after {
        display: none;
      }

      .el-tabs__header {
        margin: 0;
      }
    }

    .main-buttons {
      display: flex;
      line-height: 36px;
      margin-top: 10px;

      .main-buttons-title {
        flex: 1;
        height: 36px;
        line-height: 36px;
        font-size: 16px;
        font-weight: bold;
        color: rgba(51, 51, 51, 1);
      }
    }
  }
</style>
